﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Reflection;
using Pixysoft.Weblications.Sango.Formular;
using Pixysoft.Weblications.Sango.Dao;
using Pixysoft.Weblications.Sango.Environment;
using Pixysoft.Weblications.Sango.Constant;

namespace Pixysoft.Weblications.Sango.Command.section
{
    partial class SangoSectionHandler
    {
        public section_tradeinfo section_tradeinfo(long sectionserialcode, string targetusercode)
        {
            string usercode = SangoManager.Authentication();

            section_tradeinfo response = ReflectionManager.CreatePojo<section_tradeinfo>();
            response.Succeed = false;

            Entities.Usr_Activity myactivity = UsrActivityDao.getHistory(usercode);
            Entities.Usr_Profile targetprofile = UsrProfileDao.getUsrProfile(targetusercode);
            Entities.Cti_Section section = CitySectionHelper.searchSectionByCode(sectionserialcode);
            Entities.Usr_Building building = UsrBuildingDao.getUserBuilding(usercode, CtiBuildingTypecodeCollection.TRADE);

            long cash = SectionFormular.getTradeToCash(section, targetprofile, building.Buildinglevel);

            response.tradetimes = SectionFormular.default_trade_count - myactivity.Tradecount;
            response.cash = cash;
            response.Succeed = true;
            return response;
        }
    }

    public interface section_tradeinfo : ISangoResponse
    {
        /// <summary>
        ///  剩余可公关次数
        /// </summary>
        long tradetimes { get;set;}

        /// <summary>
        /// 公关可获取现金额
        /// </summary>
        long cash { get;set;}
    }
}
